package com.xuetang9.wordreview.controller;

import com.xuetang9.wordreview.request.WordCreatOrUpdateRequest;
import com.xuetang9.wordreview.request.WordPageRequest;
import com.xuetang9.wordreview.service.WordService;
import com.xuetang9.wordreview.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>Description:  </p>
 * <p>CreateTime:   2020/7/4 </p>
 *
 * @author fujian
 */
@RestController
@RequestMapping("word/")
public class WordController {

    @Autowired(required = true)
    private WordService wordService;

    @PostMapping("del")
    public R del(Integer id){
        wordService.del(id);
        return R.ok();
    }

    @PostMapping("save")
    public R save(@RequestBody WordCreatOrUpdateRequest request){
        wordService.creatOrUpdateWord(request);
        return R.ok();
    }

    @GetMapping("page")
    public R page(@RequestBody WordPageRequest request){
        return R.setData(wordService.page(request));
    }

}
